<?php
include('../../include/functions.inc.php');
$list = $db->query_select("cllg_career", "FK_ENTITY=" . $user->entity);
$listCycles = $db->query_select("cllg_college_cycle", "FK_ENTITY=" . $user->entity);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Asignacion de Estudiantes</title>
        <link href="../../bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
        <link href="../../css/ContentStyle.css" rel="stylesheet" type="text/css" />
        <link href="../../js/protocalendar/datepicker.css" rel="stylesheet" type="text/css" />
        <link href="../../css/tableorderer.css" rel="stylesheet" type="text/css" />
        <link href="../../js/dialog/dialog.2.0.css" rel="stylesheet" type="text/css" />
        <script src="../../js/jquery.js" type="text/javascript"></script>
        <script>jQuery.noConflict();</script>
        <script src="../../bootstrap/js/bootstrap.js"></script>
        <script src="../../js/prototype.js" type="text/javascript"></script>
        <script src="uploader.js" type="text/javascript"></script>
        <script src="../../js/jsvalidate.js" type="text/javascript"></script>
        <script src="../../js/TableOrderer.js" type="text/javascript"></script>
        <script src="../../js/dialog/dialog.2.0.js" type="text/javascript"></script>
        <script src="../../js/include.js" type="text/javascript"></script>
        <style type="text/css">
            input,
            textarea{
                width: 300px;
            }
            select{
                width: 314px;
            }
        </style>
        <script type="text/javascript">
            var cargos=null;

            var rsv;
            config=function(){ 
                rsv=new RSV({
                    formID: $(document.ASIGNACION),
                    errorFieldClass: "errorField",
                    rules: ["required,NAME,Debe buscar un Catedratico!",
                        "required,MINIMA,Debe ingresar la nota minima de aprobacion!",
                        "digits_only,MINIMA,La nota minima tiene que ser un numero!"],
                    displayType : "display-html",
                    errorHTMLItemBullet : "&#8212; ",
                    onCompleteHandler:function(){
                        waitMsg("Guardando...")
                        $(document.ASIGNACION).request({onComplete:function(r){
                                alert(r.responseText);
                                closeWait();
                                $(document.ASIGNACION).action="index.php";
                                $(document.ASIGNACION).submit();
                            }});
                    }});
            }

            addOnLoad(config);

            showUpload=function(){
                waitMsg("Cargando...");
                new Ajax.Updater("uploader","uploader.php",{onComplete:closeWait});
            }
            addOnLoad(showUpload);

            deleteFile=function(fileName){
                waitMsg("Eliminando...");
                new Ajax.Request("deletefile.php",{parameters:"filename="+fileName,
                    onComplete:function(r){
                        showUpload();
                        closeWait();
                    }});
            }

            showTeach=function(){
                var f=new Hash({tittle:'Listado de Catedraticos',url:'../teachers/list.php',
                    callback:selTeach,width:500,height:700});
                setList(null,f.toObject());
            }

            showPreview=function(){
                var f=new Hash({tittle:'Listado Notas',url:'previewNotas.php',
                    ajax:true,width:500,height:500});
                setList(null,f.toObject());
            }
            var currentTeacher=null;
            selTeach=function(s){
                currentTeacher=s;
                $("ID").value=s.ID;
                $("NAME").value=s.NOMBRES+' '+s.APELLIDOS;
            }
            loadTeacherData=function(){
                var s=currentTeacher;    
                waitMsg("Cargando...");
                new Ajax.Updater("cursos","combo.php?"+$(document.forms[0]).serialize(),
                {parameters:"ID="+$F("ID"),
                    onComplete:function(r){
                        closeWait();
                    }});
            }
        </script>
    </head>

    <body>
        <div id="tabs">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a>Carga automática de notas</a>
                </li>
            </ul>
        </div>
        <div id="tabs-cont">
            <div id="rsvErrors"></div>

            <table class=""  width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <th width="50%" scope="col"></th>
                    <th width="50%" scope="col" valign="middle">
                        <input type="button" name="cmdOk" id="cmdOk" value="Continuar" class="btn btn-info" onClick="rsv.validate();" /></th>
                </tr>
                <tr>
                    <td colspan="2">
                        <form action="data.php" method="get" name="ASIGNACION" id="ASIGNACION">
                            <input name="operation" type="hidden" id="operation" value="s" />
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td width="20%">ID CATEDRATICO</td>
                                    <td width="80%">            <input name="ID" type="text" readonly="readonly" id="ID" />
                                        <input name="buscar" onclick="showTeach()" type="button" class="btn btn-small" id="buscar"  value=".." />            </td>
                                </tr>


                                <tr>
                                    <td>NOMBRE </td>
                                    <td><input name="NAME" type="text" id="NAME" readonly="readonly" size="50" /></td>
                                </tr>

                                <tr>
                                    <td>NOTA MINIMA APROBACION</td>
                                    <td id="cursos2"><input name="MINIMA" type="text" id="MINIMA" /></td>
                                </tr>
                                <tr>
                                    <td>CICLO DE ASIGNACION</td>
                                    <td id="cursos4"><select name="CYCLE" id="CYCLE" onchange="loadTeacherData();">
                                            <option value="" selected="selected">Seleccione</option>
                                            <?php foreach ($listCycles as $it) { ?>
                                                <option value="<?php echo $it["CODE"]; ?>"><?php echo $it["CODE"]; ?> </option>
                                            <?php } ?>
                                        </select></td>
                                </tr>
                                <tr>
                                    <td>CURSOS ASIGNADOS</td>
                                    <td id="cursos"><select name="CURSO" id="CURSO">
                                        </select>
                                    </td>
                                </tr>

                            </table>
                        </form></td>
                </tr>
                <tr>
                    <td colspan="2" id="uploader">&nbsp;</td>
                </tr>
            </table>
        </div>
    </body>
</html>
